Matrices 3D

Definición:

La multiplicación se define como:

\begin{equation} (AB)C \end{equation}

Ejemplo 1:Multiplicar:

\begin{equation} \left [ \begin{matrix} 1 \\\ 2 \\\ 3 \end{matrix} \right ] \left [ \begin{matrix} 4 & 5 & 6 \end{matrix} \right ] \left [ \begin{matrix} 7 & 8 & 9 \end{matrix} \right ] \end{equation}

Primero se multiplican $A$ y $B$:

\begin{equation} \left [ \begin{matrix} 1 \\\ 2 \\\ 3 \end{matrix} \right ] \left [ \begin{matrix} 4 & 5 & 6 \end{matrix} \right ] = \left [ \begin{matrix} 4 & 5 & 6 \\\ 8 & 10 & 12 \\\ 12 & 15 & 18 \end{matrix} \right ] \end{equation}

Luego se multiplican todas las columnas de $AB$ con $C$.

\begin{equation} \left [ \begin{matrix} 4 \\\ 8 \\\ 12 \end{matrix} \right ] \left [ \begin{matrix} 7 & 8 & 9 \end{matrix} \right ] = \left [ \begin{matrix} 28 & 32 & 36 \\\ 56 & 64 & 72 \\\ 84 & 96 & 108 \end{matrix} \right ] \end{equation}\begin{equation} \left [ \begin{matrix} 5 \\\ 10 \\\ 15 \end{matrix} \right ] \left [ \begin{matrix} 7 & 8 & 9 \end{matrix} \right ] = \left [ \begin{matrix} 35 & 40 & 45 \\\ 70 & 80 & 90 \\\ 105 & 120 & 135 \end{matrix} \right ] \end{equation}\begin{equation} \left [ \begin{matrix} 6 \\\ 12 \\\ 18 \end{matrix} \right ] \left [ \begin{matrix} 7 & 8 & 9 \end{matrix} \right ] = \left [ \begin{matrix} 42 & 48 & 54 \\\ 84 & 96 & 108 \\\ 126 & 144 & 162 \end{matrix} \right ] \end{equation}

El resultado es:

\begin{equation} \left [ \begin{matrix} 1 \\\ 2 \\\ 3\ \end{matrix} \right ] \left [ \begin{matrix} 4 & 5 & 6 \end{matrix} \right ] \left [ \begin{matrix} 7 & 8 & 9 \end{matrix} \right ] = \left [ \left [ \begin{matrix} 28 & 32 & 36 \\\ 56 & 64 & 72 \\\ 84 & 96 & 108 \end{matrix} \right ] \left [ \begin{matrix} 35 & 40 & 45 \\\ 70 & 80 & 90 \\\ 105 & 120 & 135 \end{matrix} \right ] \left [ \begin{matrix} 42 & 48 & 54 \\\ 84 & 96 & 108 \\\ 126 & 144 & 162 \end{matrix} \right ] \right ] \end{equation}

Ejemplo gráfico:


In [1]:
from mpl_toolkits.mplot3d import Axes3D
import matplotlib.pyplot as plt

fig = plt.figure()
ax = fig.gca(projection='3d')

ax.text(1, 0, 0, "1", color='red')
ax.text(2, 0, 0, "2", color='red')
ax.text(3, 0, 0, "3", color='red')

ax.text(0, 1, 0, "4", color='blue')
ax.text(0, 2, 0, "5", color='blue')
ax.text(0, 3, 0, "6", color='blue')

ax.text(0, 0, 1, "7", color='green')
ax.text(0, 0, 2, "8", color='green')
ax.text(0, 0, 3, "9", color='green')

ax.set_xlim3d(0, 5)
ax.set_ylim3d(0, 5)
ax.set_zlim3d(0, 5)

ax.set_xlabel('Eje x')
ax.set_ylabel('Eje y')
ax.set_zlabel('Eje z')

ax.view_init(17, 24)

plt.show()



In [2]:
from mpl_toolkits.mplot3d import Axes3D
import matplotlib.pyplot as plt

fig = plt.figure()
ax = fig.gca(projection='3d')

ax.text(1, 0, 0, "1", color='red')
ax.text(2, 0, 0, "2", color='red')
ax.text(3, 0, 0, "3", color='red')

ax.text(0, 1, 0, "4", color='blue')
ax.text(0, 2, 0, "5", color='blue')
ax.text(0, 3, 0, "6", color='blue')

ax.text(0, 0, 1, "7", color='green')
ax.text(0, 0, 2, "8", color='green')
ax.text(0, 0, 3, "9", color='green')

## 4  5  6
## 8 10 12
##12 15 18

ax.text(1, 1, 0, "4", color='magenta')
ax.text(2, 1, 0, "8", color='magenta')
ax.text(3, 1, 0, "12", color='magenta')

ax.text(1, 2, 0, "5", color='orange')
ax.text(2, 2, 0, "10", color='orange')
ax.text(3, 2, 0, "15", color='orange')

ax.text(1, 3, 0, "6", color='purple')
ax.text(2, 3, 0, "12", color='purple')
ax.text(3, 3, 0, "18", color='purple')

ax.set_xlim3d(0, 5)
ax.set_ylim3d(0, 5)
ax.set_zlim3d(0, 5)

ax.set_xlabel('Eje x')
ax.set_ylabel('Eje y')
ax.set_zlabel('Eje z')

ax.view_init(17, 24)

plt.show()



In [3]:
from mpl_toolkits.mplot3d import Axes3D
import matplotlib.pyplot as plt

fig = plt.figure()
ax = fig.gca(projection='3d')

ax.text(1, 0, 0, "1", color='red')
ax.text(2, 0, 0, "2", color='red')
ax.text(3, 0, 0, "3", color='red')

ax.text(0, 1, 0, "4", color='blue')
ax.text(0, 2, 0, "5", color='blue')
ax.text(0, 3, 0, "6", color='blue')

ax.text(0, 0, 1, "7", color='green')
ax.text(0, 0, 2, "8", color='green')
ax.text(0, 0, 3, "9", color='green')

##28 32  36
##56 64  72
##84 96 108
##
## 35  40  45
## 70  80  90
##105 120 135
##
## 42  48  54
## 84  96 108
##126 144 162

ax.text(1, 1, 0, "28", color='magenta')
ax.text(2, 1, 0, "56", color='magenta')
ax.text(3, 1, 0, "84", color='magenta')
ax.text(1, 1, 1, "32", color='magenta')
ax.text(2, 1, 1, "64", color='magenta')
ax.text(3, 1, 1, "96", color='magenta')
ax.text(1, 1, 2, "36", color='magenta')
ax.text(2, 1, 2, "72", color='magenta')
ax.text(3, 1, 2, "108", color='magenta')

ax.text(1, 2, 0, "35", color='orange')
ax.text(2, 2, 0, "70", color='orange')
ax.text(3, 2, 0, "105", color='orange')
ax.text(1, 2, 1, "40", color='orange')
ax.text(2, 2, 1, "80", color='orange')
ax.text(3, 2, 1, "120", color='orange')
ax.text(1, 2, 2, "45", color='orange')
ax.text(2, 2, 2, "90", color='orange')
ax.text(3, 2, 2, "135", color='orange')

ax.text(1, 3, 0, "42", color='purple')
ax.text(2, 3, 0, "84", color='purple')
ax.text(3, 3, 0, "126", color='purple')
ax.text(1, 3, 1, "48", color='purple')
ax.text(2, 3, 1, "96", color='purple')
ax.text(3, 3, 1, "144", color='purple')
ax.text(1, 3, 2, "54", color='purple')
ax.text(2, 3, 2, "108", color='purple')
ax.text(3, 3, 2, "162", color='purple')


ax.set_xlim3d(0, 5)
ax.set_ylim3d(0, 5)
ax.set_zlim3d(0, 5)

ax.set_xlabel('Eje x')
ax.set_ylabel('Eje y')
ax.set_zlabel('Eje z')

ax.view_init(17, 24)

plt.show()